package com.luweijie.utils;

import com.google.common.reflect.TypeToken;
import com.google.gson.GsonBuilder;

import java.lang.reflect.Type;
import java.util.Map;

public class JsonUtils {

    public static <K, V> Map<K, V> stringToMap(String string) {
        return (Map)stringToTypeOfT(string, (new TypeToken<Map<K, V>>() {
        }).getType());
    }
    public static <T> T stringToTypeOfT(String string, Type typeOfT) {
        return (new GsonBuilder()).setDateFormat("yyyy-MM-dd HH:mm:ss").create().fromJson(string, typeOfT);
    }
}
